这个软件可以设置开机启动、窗体置顶、隐藏鼠标、全屏、获取目录文件、重启软件功能。
private void WriteRegistry()
{
string strName = Application.ExecutablePath;
if (File.Exists(strName))
{
string strNewName = Path.GetFileName(strName);
RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (reg == null)
{
reg = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
}
else
{
if (reg.GetValue(strNewName) == null)
{
reg.SetValue(strNewName, strName);
}
}
}
}
void Ckbox_autorunCheckedChanged(object sender, EventArgs e)
{
if(ckbox_autorun.Checked==true)
WriteRegistry();
else
{
}
}
void Ckbox_topCheckedChanged(object sender, EventArgs e)
{ if(ckbox_top.Checked==true)
TopMost=true;//窗体置顶
else
TopMost=false;//取消窗体置顶
}
void CkBox_cursorCheckedChanged(object sender, EventArgs e)
{
if(ckBox_cursor.Checked==true)
Cursor.Hide();//=true;//窗体置顶
else
Cursor.Show();
}
void Rdo_allScreenCheckedChanged(object sender, EventArgs e)
{
if(rdo_allScreen.Checked==true)
{
rdo_default.Checked=false;
this.FormBorderStyle = FormBorderStyle.None;//设置窗体为无边框样式
this.WindowState = FormWindowState.Maximized;//最大化显示窗体
}else
{
rdo_allScreen.Checked=false;
rdo_default.Checked=true;
this.FormBorderStyle = FormBorderStyle.Sizable;//设置窗体为有边框样式
this.WindowState = FormWindowState.Normal;//正常显示窗体
}
}
List<string> strfile = new List<string>();
/// <summary>
/// 递归获取文件
/// </summary>
/// <param name="path">文件目录</param>
private void searchFile(string path)
{
try
{
//获得当前目录下的所有文件
string[] files = Directory.GetFiles(path, "*.*");
foreach (string f in files)
{
//写入文件
strfile.Add(f);
}
//获得当前目录下的所有目录
string[] dirs = Directory.GetDirectories(path);
foreach (string dir in dirs)
{
searchFile(dir);
}
}
catch { }
}
private void button1_Click(object sender, EventArgs e)
{
progressBar.Value = 0;
string path = @"d:\media";
if (textBox1.Text != "")
{
path = textBox1.Text;
}
searchFile(path);
progressBar.Maximum = strfile.Count;
for (int i = 0; i < strfile.Count; i )
{
richTextBox1.Text = (strfile[i].ToString() "\r\n");
progressBar.Value ;
Text = i.ToString();
}
MessageBox.Show("读取完毕!");
}
private void button2_Click(object sender, EventArgs e)
{
Application.Restart();
}
评论